package bank;

/**
An account that earns interest at a fixed rate.
*/
public class SavingsAccount extends BankAccount
{
	private double interestRate;
	
	/**
	Constructs a bank account with a given interest rate.
	@param interestRate the interest rate
	*/
	public SavingsAccount(int accountNumber, double initialBalance, double interestRate)
	{
		super(accountNumber, initialBalance);
		this.interestRate = interestRate;
	}
	
	/**
	Adds the earned interest to the account balance.
	*/
	public void addInterest()
	{
		double interest = getBalance() * interestRate / 100;
		deposit(interest);
	}
}